package com.inspectortime.domain.util;

import java.util.Comparator;

import com.inspectortime.domain.type.Name;

/**
 * Simply sorts Name types by last name, then first name, in ascending order
 * 
 * @author bones
 *
 */
public class NameComparator implements Comparator {
	
	public int compare(Object arg1, Object arg2) {
		Name name1 = (Name) arg1;
		Name name2 = (Name) arg2;
		
		 if (name1.getLast().equals(name2.getLast())) {
  		   return name1.getFirst().compareToIgnoreCase(name2.getFirst());
  	   }
  	   return name1.getLast().compareToIgnoreCase(name2.getLast());
		
	}

}
